#ifndef HDCAMERA_H
#define HDCAMERA_H

#include <QObject>
#include <QThread>
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>

enum CameraInitResult
{
	Camera_Init_Failed,
	Camera_Init_Successful
};

class HDCamera : public QThread
{
	Q_OBJECT

public:
	HDCamera(QObject* parent = 0, int frameRate=25, int frameWidth=320, int frameHeight=240);
	~HDCamera();

	CameraInitResult Initialize(int deviceIndex = 0);
	void StartCapture();
	void PauseCapture(bool pause = true);
	void ReleaseCapture();
	IplImage* frame();

protected:
	void run();

signals:
	void NewFrameCaptured(IplImage* frame);

private:
	int _deviceIndex;
	int _cameraIndex;
	int _frameRate;
	int _frameWidth;
	int _frameHeight;
	IplImage *_frame;
	bool _pause;

	CvCapture *_capture;

	bool bInitialize;
};

#endif // HDCAMERA_H
